package org.zfes.snowier.common.monitor.mysql;

import java.util.concurrent.Executors;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.zfes.snowier.common.monitor.mysql.dump.MysqlDumpRecover;

@Configuration
//@PropertySource(value = "classpath:config/mysql-dump.yml")
@PropertySource(value = {"file:${config.path}"}, encoding="utf-8")
public class ScheduleConfig implements SchedulingConfigurer {
	
	
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(Executors.newScheduledThreadPool(1));
    }
    
    @Scheduled(cron = "${dumpPeriodCron}")  
    public void doDumpTask() {
    	//System.out.println("---doDumpTask-----");
    	MysqlDumpRecover.getInsFromOuterConfig("./mysql-dump.yml").doDump();
    	//MysqlDumpRecover.getInsFromInnerConfig("config/mysql-dump.yml").doDump();
    }
    
}
